<template>
  <div class="header">
    <img class="logo" @click="$router.push('/')" src="@/assets/img/logo.png">
    <div>
      <van-icon name="search" /> <span>请入内容</span>
    </div>
    <div>
      <img @click="$router.push('/userinfo')" v-if=" profile" :src="profile.user_img">
      <img v-else @click="$router.push('/login')" src="@/assets/img/login.png">
      <p>下载App</p>
    </div>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  name: 'headerIndex',
  props: {
    user: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      imgUrl: null
    }
  },
  watch: {
    // imgUrl() {
    //   return getItem('user').user_img || '@/assets/img/login.png'
    // }
  },
  computed: {
    ...mapState(['profile'])
  }
}
</script>
<style lang="less" scoped>
.header {
  height: 46px;
  width: 100%;
  line-height: 46px;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .logo {
    height: 32px;
  }
  div {
    height: 100%;
  }
  div:nth-child(3) {
    display: flex;
    align-items: center;
    margin-right: 14px;
    width: 120px;
    height: 34px;
    img {
      width: 34px;
      height: 34px;
      border-radius: 50%;
      vertical-align: middle;
      margin-right: 8px;
    }
    p {
      margin: 0;
      width: 78px;
      height: 28px;
      line-height: 28px;
      font-size: 14px;
      border-radius: 5px;
      background-color: #fb7299;
      color: #fff;
      text-align: center;
    }
  }
  div:nth-child(2) {
    width: 100%;
    height: 28px;
    line-height: 28px;
    padding: 0 10px;
    margin: 0 5px 0 0;
    background-color: #e6e6e6;

    font-size: 16px;
    border-radius: 18px;
    .van-icon {
      vertical-align: middle;
    }
    span {
      font-size: 14px;
    }
  }
}
</style>
